package com.yuejian_06.yuejian_06.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.yuejian_06.yuejian_06.Listener.LoginListener;
import com.yuejian_06.yuejian_06.R;
import com.yuejian_06.yuejian_06.adapter.CoachAdapter;
import com.yuejian_06.yuejian_06.bean.CoachBean;
import com.yuejian_06.yuejian_06.model.CoachModel;

import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class CoachFragment extends Fragment {
    RecyclerView recyclerView;

    private LoginListener<List<CoachBean>> Listener=new LoginListener<List<CoachBean>>() {
        @Override
        public void onResponse(List<CoachBean> o) {
            List<CoachBean> mDataList=o;
            recyclerView.setAdapter(new CoachAdapter(getActivity(),mDataList));//设置适配器
        }
        @Override
        public void onFail(String msg) {
            Toast.makeText(getActivity().getApplicationContext(),"失败了",Toast.LENGTH_SHORT).show();

        }
    };

    public CoachFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_coach, container, false);
        recyclerView = (RecyclerView) view.findViewById(R.id.coach_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));// 布局
        CoachModel coachModel=new CoachModel();
        coachModel.coachList(Listener);

        return view;
    }

}
